<html>
  <head>
    <script src="/third_party/static/jquery-2.0.3/jquery.min.js"></script>
    <script>
      var GLOBALS = {};
      GLOBALS.buttonText = JSON.parse('{{buttonText|js_string}}');
    </script>
  </head>

  <body onload="onWidgetLoad()">
    <button id="submitButton" type="button" onclick="submitAnswer()"></button>

    <script>
      $(document).ready(function() {
        $('#submitButton').text(GLOBALS.buttonText);
      });

      window.onWidgetLoad = function() {
        window.parent.postMessage(
          {'widgetHeight': document.body.scrollHeight},
          window.location.protocol + '//' + window.location.host);
      };

      var submitAnswer = function() {
  	    if (parent.location.pathname.indexOf('/learn') === 0) {
          window.parent.postMessage(
            JSON.stringify({'submit': ''}),
            window.location.protocol + '//' + window.location.host
          );
        }
      };
    </script>
  </body>
</html>
